<template>
  <div class="aecc">
    <!-- 门禁 -->
    <el-dialog
      width="500px"
      custom-class="customWidth"
      center
      :before-close="closeDialog"
      title="门禁信息"
      :close-on-click-modal="false"
      :visible.sync="eidtDialogFormVisible"
    >
      <el-form
        :model="editdataForm"
        :rules="eidtataRule"
        ref="editdataForm"
        @keyup.enter.native="addataFormSubmit()"
        label-width="80px"
        :disabled="!isauth('access_edit')"
      >
        <el-form-item label="设备名称" prop="terminalName">
          <el-col :span="15">
            <el-input v-model="editdataForm.terminalName" size="mini" disabled></el-input>
          </el-col>
        </el-form-item>
        <el-form-item label="设备编号" prop="terminalCode">
          <el-col :span="15">
            <el-input v-model="editdataForm.terminalCode" size="mini" disabled></el-input>
          </el-col>
        </el-form-item>
        <el-form-item label="设备型号" prop="devicemodel">
          <el-col :span="15">
            <el-select
              v-model="editdataForm.devicemodel"
              placeholder="请选择"
              style="width:100%"
              size="mini"
              disabled
            >
              <el-option
                v-for="item in terminaloption"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </el-col>
        </el-form-item>

        <el-form-item label="ip地址" prop="ip" v-if="!isNewAcce(editdataForm.devicemodel)">
          <el-col :span="15">
            <el-input v-model="editdataForm.ip" size="mini"></el-input>
          </el-col>
        </el-form-item>
        <el-form-item label="端口号" prop="port" v-if="!isNewAcce(editdataForm.devicemodel)">
          <el-col :span="15">
            <el-input v-model="editdataForm.port" size="mini"></el-input>
          </el-col>
        </el-form-item>
        <!-- 网关 -->
        <el-form-item label="网关" prop="acceWanguang" v-show="isNewAcce(editdataForm.devicemodel)">
          <el-col :span="15">
            <el-select
              v-model="editdataForm.acceWanguang"
              placeholder="请选择"
              size="mini"
              style="width: 100%"
              value-key="value"
            >
              <el-option
                v-for="item in acceWanguangOption"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </el-col>
        </el-form-item>
        <!-- 进出方向 -->
        <el-form-item label="进出方向" prop="openType" v-show="isNewAcce(editdataForm.devicemodel)">
          <el-col :span="15">
            <el-select
              v-model="editdataForm.openType"
              placeholder="请选择"
              size="mini"
              style="width: 100%"
            >
              <el-option
                v-for="item in openTypeOption"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </el-col>
        </el-form-item>
        <!-- 门编号 -->
        <el-form-item label="门编号" prop="doorCode" v-show="isNewAcce(editdataForm.devicemodel)">
          <el-col :span="15">
            <el-select
              v-model="editdataForm.doorCode"
              placeholder="请选择"
              size="mini"
              style="width: 100%"
              disabled
            >
              <el-option v-for="item in 2" :key="item" :label="item" :value="item"></el-option>
            </el-select>
          </el-col>
        </el-form-item>
        <el-form-item label="人脸机ip" prop="doorFaceIp" v-if="isNewAcce(editdataForm.devicemodel)">
          <el-col :span="15">
            <el-input v-model="editdataForm.doorFaceIp" size="mini"></el-input>
          </el-col>
        </el-form-item>
        <el-form-item label="是否启用">
          <el-col :span="15">
            <el-checkbox v-model="editdataForm.deviceisuse"></el-checkbox>
          </el-col>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer" v-if="isauth('access_edit')">
        <el-button @click="editvisible()">取消</el-button>
        <el-button type="primary" @click="editdataFormSubmit()">确定</el-button>
      </span>
    </el-dialog>
    <!-- 中继修改弹窗 -->
    <el-dialog
      width="500px"
      custom-class="customWidth"
      center
      :before-close="repeatercloseDialog"
      title="修改路由信息"
      :close-on-click-modal="false"
      :visible.sync="repeaterDialogFormVisible"
    >
      <el-form
        :model="repeaterdataForm"
        :rules="repeaterdataFormRule"
        ref="repeaterdataForm"
        label-width="100px"
        :disabled="!isauth('access_edit')"
      >
        <el-form-item label="第一条中继" prop="repeater1">
          <el-col :span="15">
            <el-select
              v-model="repeaterdataForm.repeater1"
              placeholder="请选择"
              style="width:100%"
              size="mini"
              @change="repeaterslect"
            >
              <el-option
                v-for="item in repeateroption"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </el-col>
        </el-form-item>
        <el-form-item label="第二条中继" prop="repeater2">
          <el-col :span="15">
            <el-select
              v-model="repeaterdataForm.repeater2"
              placeholder="请选择"
              style="width:100%"
              size="mini"
              @change="repeaterslect2"
            >
              <el-option
                v-for="item in repeateroption"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </el-col>
        </el-form-item>
        <el-form-item label="第三条中继" prop="repeater3">
          <el-col :span="15">
            <el-select
              v-model="repeaterdataForm.repeater3"
              placeholder="请选择"
              style="width:100%"
              size="mini"
              @change="repeaterslect3"
            >
              <el-option
                v-for="item in repeateroption"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </el-col>
        </el-form-item>
        <el-form-item label="第四条中继" prop="repeater4">
          <el-col :span="15">
            <el-select
              v-model="repeaterdataForm.repeater4"
              placeholder="请选择"
              style="width:100%"
              size="mini"
              @change="repeaterslect4"
            >
              <el-option
                v-for="item in repeateroption"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </el-col>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer" v-if="isauth('access_edit')">
        <el-button @click="repeatervisible()">取消</el-button>
        <el-button type="primary" @click="repeaterdataFormSubmit()">确定</el-button>
      </span>
    </el-dialog>
    <!-- 参数模板修改弹窗 -->
    <el-dialog
      width="500px"
      custom-class="customWidth"
      center
      :before-close="parametercloseDialog"
      title="修改参数模板"
      :close-on-click-modal="false"
      :visible.sync="parameterDialogFormVisible"
    >
      <el-form
        :model="parameterdataForm"
        :rules="parameterRule"
        ref="parameterdataForm"
        label-width="80px"
        :disabled="!isauth('access_edit')"
      >
        <el-form-item label="模板" prop="template">
          <el-col :span="15">
            <el-select
              v-model="parameterdataForm.template"
              placeholder="请选择"
              style="width:100%"
              size="mini"
            >
              <el-option
                v-for="item in templateoption"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </el-col>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer" v-if="isauth('access_edit')">
        <el-button @click="parametervisible()">取消</el-button>
        <el-button type="primary" @click="parameterdataFormSubmit()">确定</el-button>
      </span>
    </el-dialog>

    <!-- 门资料管理 -->
    <el-dialog
      width="600px"
      custom-class="customWidth"
      center
      :before-close="personnelcloseDialog"
      title="门资料管理"
      :close-on-click-modal="false"
      :visible.sync="personnelFormVisible"
    >
      <door-data-management
        v-if="operatinincomesummaryofconsmptionVisible"
        ref="operatinincomesummaryofconsumption"
        :unitGuid="changeschoolid"
        :terminalGuid="terminalGuid"
      ></door-data-management>
    </el-dialog>
    <!-- 通讯记录 -->
    <el-dialog
      width="90%"
      custom-class="customWidth"
      center
      :before-close="recordscloseDialog"
      :title="recordsTitle"
      :close-on-click-modal="false"
      :visible.sync="recordsFormVisible"
    >
      <!-- <records-details v-if="recordsdetailsVisible" ref="recordsdetails" :roomGuid="roomGuid"></records-details> -->
    </el-dialog>
  </div>
</template>

<script>
import DoorDataManagement from './door-data-management'
// import RecordsDetails from "./records-details";

export default {
  data() {
    ////^([1-9]\d{0,2}|[1-4]\d{3}|5000)$/
    //网关端口检验
    let checkport = (rule, value, callback) => {
      let portReg = /^[1-9]$|(^[1-9][0-9]$)|(^[1-9][0-9][0-9]$)|(^[1-9][0-9][0-9][0-9]$)|(^[1-6][0-5][0-5][0-3][0-5]$)/
      if (value == '') {
        callback(new Error('端口不能为空'))
      } else if (!portReg.test(value)) {
        callback(new Error('端口格式错误！'))
      } else {
        callback()
      }
    }
    //中继
    let checkrepeaterid = (rule, value, callback) => {
      let repeateridReg = /^((25[0-5]|2[0-4]\d|[01]?\d\d?)($|(?!\.$)\.)){4}$/
      if (value == '') {
        callback(new Error('ip不能为空'))
      } else if (!repeateridReg.test(value)) {
        callback(new Error('ip格式错误！'))
      } else {
        callback()
      }
    }
    return {
      operatinincomesummaryofconsmptionVisible: true,
      // 通行记录
      recordsTitle: '房间通行记录',
      recordsdetailsVisible: true,
      datetime: [],
      consumptionpoint: '',
      // 房间id
      roomGuid: '',
      radio: 0,
      // 弹窗显示数据
      eidtDialogFormVisible: false,
      repeaterDialogFormVisible: false,
      parameterDialogFormVisible: false,
      personnelFormVisible: false,
      recordsFormVisible: false,
      terminaloption: [],
      buildingGuid: '',
      unitGuid: '',
      openTypeOption: [
        { label: '进门', value: 0 },
        { label: '出门', value: 1 }
      ],
      editdataForm: {
        terminalCode: '',
        terminalName: '',
        devicemodel: '',
        deviceisuse: false,
        terminalGuid: '',
        port: '',
        ip: '',
        acceWanguang: '',
        openType: '',
        doorCode: '',
        doorFaceIp: ''
      },
      eidtataRule: {
        devicemodel: [
          { required: true, message: '设备型号必须选择', trigger: 'blur' }
        ],
        ip: [
          { required: true, message: '必须填写ip', trigger: 'blur' },
          { required: true, validator: checkrepeaterid, trigger: 'blur' }
        ],
        port: [{ required: true, validator: checkport, trigger: 'blur' }]
      },

      //中继
      repeateroption: [],
      repeaterdataForm: {
        repeater1: '',
        repeater2: '',
        repeater3: '',
        repeater4: '',
        controllerGuid: ''
      },
      repeaterdataFormRule: {},

      //模板
      parameterdataForm: {
        template: ''
      },
      templateoption: [],
      parameterRule: {},

      roomGuidList: [],
      // 设备编号
      terminalGuid: '',

      /**门禁处理 {modelId: 70,modelName: "A1262T"}*/
      // 新的门禁类型
      newAccesscontrol: [70],
      // 门禁网关
      acceWanguangOption: []
    }
  },
  props: ['buttonindex'],
  components: {
    DoorDataManagement
    // RecordsDetails
  },
  computed: {
    changeschoolid: {
      get() {
        return this.$store.state.user.changeschoolid
      }
    }
  },
  methods: {
    /**
     * 门禁处理
     */
    // 判断是否存在
    isNewAcce(newAcce) {
      return this.newAccesscontrol.includes(newAcce)
    },
    // 获取门禁网关
    getAceeWangguan(val, buildingGuid, layers) {
      this.$http({
        url: this.$http.adornUrl('/api/v1/device/controller-entrance-pithy'),
        method: 'post',
        data: this.$http.adornData({
          messageContent: {
            buildingGuid: buildingGuid,
            layer: layers,
            controllerModel: val
          },
          messageType: 0
        })
      }).then(({ data }) => {
        if (data.messageCode == 200) {
          let Arr = data.messageContent
          this.acceWanguangOption = []
          for (var i = 0; i < Arr.length; i++) {
            var itemObj = {
              label: Arr[i].controllerName,
              value: Arr[i].controllerGuid,
              type: 21
            }
            this.acceWanguangOption.push(itemObj)
          }
        } else {
          this.$message.error(data.errorMessage)
        }
      })
    },

    editvisible() {
      this.$refs['editdataForm'].resetFields()
      this.eidtDialogFormVisible = false
    },
    init(item, unitGuid, buildingGuid, layers) {
      console.log(unitGuid)
      this.roomGuid = item.roomGuid
      this.eidtDialogFormVisible = true
      this.unitGuid = unitGuid
      this.editdataForm.terminalCode = item.terminalCode
      this.editdataForm.terminalName = item.terminalName
      this.editdataForm.terminalGuid = item.terminalGuid
      this.editdataForm.devicemodel = item.modelId
      this.editdataForm.ip = item.ip
      this.editdataForm.port = item.port
      this.editdataForm.deviceisuse = item.isUse == 1 ? true : false

      this.editdataForm.acceWanguang = item.controllerGuid
      this.editdataForm.openType = item.openType
      this.editdataForm.doorCode = item.doorCode
      this.editdataForm.doorFaceIp = item.doorFaceIp
      this.getAceeWangguan(this.editdataForm.devicemodel, buildingGuid, layers)
      this.terminalselect()
    },
    closeDialog(done) {
      this.$refs['editdataForm'].resetFields()
      done()
    },
    //设备型号选项
    terminalselect() {
      this.terminaloption = []
      this.$http({
        url: this.$http.adornUrl('/terminal/terminal-model-select'),
        method: 'post',
        data: this.$http.adornData({
          messageContent: {
            terminalType: 21,
            unitGuid: this.unitGuid
          },
          messageType: 0
        })
      }).then(({ data }) => {
        console.log(data)
        if (data.messageCode == 200) {
          let Arr = data.messageContent
          if (this.terminaloption.length == 0) {
            for (var i = 0; i < Arr.length; i++) {
              var itemObj = {
                label: Arr[i].modelName,
                value: Arr[i].modelId
              }
              this.terminaloption.push(itemObj)
            }
          }
        } else {
          this.$message.error(data.errorMessage)
        }
      })
    },
    //修改设备型号
    editdataFormSubmit() {
      this.$refs['editdataForm'].validate(valid => {
        if (valid) {
          let portReg = /^((25[0-5]|2[0-4]\d|[01]?\d\d?)($|(?!\.$)\.)){4}$/
          let portReg1 = /^[1-9]$|(^[1-9][0-9]$)|(^[1-9][0-9][0-9]$)|(^[1-9][0-9][0-9][0-9]$)|(^[1-6][0-5][0-5][0-3][0-5]$)/
          let messageContent = {}
          if (this.isNewAcce(this.editdataForm.devicemodel)) {
            if (this.editdataForm.doorFaceIp != '') {
              if (!portReg.test(this.editdataForm.doorFaceIp)) {
                this.$message.error('人脸机ip格式不正确')
                return
              }
            }
            messageContent = {
              isUse: this.editdataForm.deviceisuse == true ? 1 : 0,
              unitGuid: this.unitGuid,
              terminalModel: this.editdataForm.devicemodel,
              terminalGuid: this.editdataForm.terminalGuid,
              controllerGuid: this.editdataForm.acceWanguang,
              openType: this.editdataForm.openType,
              doorCode: this.editdataForm.doorCode,
              doorFaceIp: this.editdataForm.doorFaceIp
            }
          } else {
            messageContent = {
              isUse: this.editdataForm.deviceisuse == true ? 1 : 0,
              unitGuid: this.unitGuid,
              terminalModel: this.editdataForm.devicemodel,
              terminalGuid: this.editdataForm.terminalGuid,
              ip: this.editdataForm.ip,
              port: this.editdataForm.port
            }
          }
          console.log(messageContent)
          this.$http({
            url: this.$http.adornUrl(
              '/terminal/entrance/update-entrance-terminal-model'
            ),
            method: 'post',
            data: this.$http.adornData({
              messageContent: messageContent,
              messageType: 0
            })
          }).then(({ data }) => {
            console.log(data)
            if (data.messageCode == 200) {
              this.$message({
                type: 'success',
                message: '修改成功!',
                duration: 200,
                onClose: () => {
                  this.$emit('refreshDataList', this.buttonindex + 1)
                  this.eidtDialogFormVisible = false
                }
              })
            } else {
              this.$message.error(data.errorMessage)
            }
          })
        } else {
          return false
        }
      })
    },
    //修改中继
    relayinit(item, unitGuid, buildingid) {
      this.roomGuidList = []
      console.log(item)
      this.roomGuidList.push(item.roomGuid)
      this.buildingGuid = buildingid
      this.repeaterdataForm.controllerGuid = item.controllerGuid
      this.unitGuid = unitGuid
      this.repeaterdataForm.terminalGuid = item.terminalGuid
      this.repeaterdataForm.repeater1 = item.repeaterGuid1
      this.repeaterdataForm.repeater2 = item.repeaterGuid2
      this.repeaterdataForm.repeater3 = item.repeaterGuid3
      this.repeaterdataForm.repeater4 = item.repeaterGuid4
      this.repeaterlist()
      this.repeaterDialogFormVisible = true
    },
    repeatercloseDialog(done) {
      this.$refs['repeaterdataForm'].resetFields()
      done()
    },
    repeatervisible() {
      this.$refs['repeaterdataForm'].resetFields()
      this.repeaterDialogFormVisible = false
    },
    repeaterdataFormSubmit() {
      this.$http({
        url: this.$http.adornUrl('/terminal/bind-terminal-room-repeater'),
        method: 'post',
        data: this.$http.adornData({
          messageContent: {
            repeater1: this.repeaterdataForm.repeater1,
            repeater2: this.repeaterdataForm.repeater2,
            repeater3: this.repeaterdataForm.repeater3,
            repeater4: this.repeaterdataForm.repeater4,
            roomGuidList: this.roomGuidList,
            terminalType: 21
          },
          messageType: 0
        })
      }).then(({ data }) => {
        if (data.messageCode == 200) {
          this.$message({
            type: 'success',
            message: '修改成功!',
            duration: 200,
            onClose: () => {
              this.$emit('refreshDataList', this.buttonindex + 1)
              this.repeaterDialogFormVisible = false
            }
          })
        } else {
          this.$message.error(data.errorMessage)
        }
      })
    },
    repeaterlist() {
      this.repeateroption = []
      this.$http({
        url: this.$http.adornUrl('/terminal/terminal-repeater-list'),
        method: 'post',
        data: this.$http.adornData({
          messageContent: {
            buildingGuid: this.buildingGuid,
            controllerGuid: this.repeaterdataForm.controllerGuid,
            terminalGuid: this.repeaterdataForm.terminalGuid,
            unitGuid: this.unitGuid
          },
          messageType: 0
        })
      }).then(({ data }) => {
        if (data.messageCode == 200) {
          let Arr = data.messageContent
          if (Arr) {
            for (var i = 0; i < Arr.length; i++) {
              var itemObj = {
                label: Arr[i].terminalName,
                value: Arr[i].terminalGuid
              }
              this.repeateroption.push(itemObj)
            }
          }
        } else {
          this.$message.error(data.errorMessage)
        }
      })
    },
    repeaterslect() {
      if (this.repeaterdataForm.repeater1 == this.repeaterdataForm.repeater2) {
        this.$message({
          message: '当前选择与第二心跳中继冲突',
          type: 'warning'
        })
        this.repeaterdataForm.repeater1 = ''
        return
      }
      if (this.repeaterdataForm.repeater1 == this.repeaterdataForm.repeater3) {
        this.$message({
          message: '当前选择与第三心跳中继冲突',
          type: 'warning'
        })
        this.repeaterdataForm.repeater1 = ''
        return
      }
      if (this.repeaterdataForm.repeater1 == this.repeaterdataForm.repeater4) {
        this.$message({
          message: '当前选择与第四心跳中继冲突',
          type: 'warning'
        })
        this.repeaterdataForm.repeater1 = ''
        return
      }
    },
    repeaterslect2() {
      if (this.repeaterdataForm.repeater2 == this.repeaterdataForm.repeater1) {
        this.$message({
          message: '当前选择与第一心跳中继冲突',
          type: 'warning'
        })
        this.repeaterdataForm.repeater2 = ''
        return
      }
      if (this.repeaterdataForm.repeater2 == this.repeaterdataForm.repeater3) {
        this.$message({
          message: '当前选择与第三心跳中继冲突',
          type: 'warning'
        })
        this.repeaterdataForm.repeater2 = ''
        return
      }
      if (this.repeaterdataForm.repeater2 == this.repeaterdataForm.repeater4) {
        this.$message({
          message: '当前选择与第四心跳中继冲突',
          type: 'warning'
        })
        this.repeaterdataForm.repeater2 = ''
        return
      }
    },
    repeaterslect3() {
      if (this.repeaterdataForm.repeater3 == this.repeaterdataForm.repeater1) {
        this.$message({
          message: '当前选择与第一心跳中继冲突',
          type: 'warning'
        })
        this.repeaterdataForm.repeater3 = ''
        return
      }
      if (this.repeaterdataForm.repeater3 == this.repeaterdataForm.repeater2) {
        this.$message({
          message: '当前选择与第二心跳中继冲突',
          type: 'warning'
        })
        this.repeaterdataForm.repeater3 = ''
        return
      }
      if (this.repeaterdataForm.repeater3 == this.repeaterdataForm.repeater4) {
        this.$message({
          message: '当前选择与第四心跳中继冲突',
          type: 'warning'
        })
        this.repeaterdataForm.repeater3 = ''
        return
      }
    },
    repeaterslect4() {
      if (this.repeaterdataForm.repeater4 == this.repeaterdataForm.repeater1) {
        this.$message({
          message: '当前选择与第一心跳中继冲突',
          type: 'warning'
        })
        this.repeaterdataForm.repeater4 = ''
        return
      }
      if (this.repeaterdataForm.repeater4 == this.repeaterdataForm.repeater2) {
        this.$message({
          message: '当前选择与第二心跳中继冲突',
          type: 'warning'
        })
        this.repeaterdataForm.repeater4 = ''
        return
      }
      if (this.repeaterdataForm.repeater4 == this.repeaterdataForm.repeater3) {
        this.$message({
          message: '当前选择与第三心跳中继冲突',
          type: 'warning'
        })
        this.repeaterdataForm.repeater4 = ''
        return
      }
    },
    //参数模板修改
    parameterinit(item, unitGuid) {
      this.roomGuidList = []
      console.log(item.modelId)
      this.roomGuidList.push(item.roomGuid)
      this.unitGuid = unitGuid
      this.parameterdataForm.template = item.templateGuid
      this.terminaltemplate(item.modelId)
      this.parameterDialogFormVisible = true
    },
    parametercloseDialog(done) {
      this.$refs['parameterdataForm'].resetFields()
      done()
    },
    parametervisible() {
      this.$refs['parameterdataForm'].resetFields()
      this.parameterDialogFormVisible = false
    },
    //获取设备模板
    terminaltemplate(typeId) {
      let terminalType
      if (typeId == '13' || typeId == '15') {
        console.log(typeId)
        terminalType = 21
      } else {
        terminalType = 23
      }
      this.$http({
        url: this.$http.adornUrl('/terminal/template-model-select'),
        method: 'post',
        data: this.$http.adornData({
          messageContent: {
            terminalType: terminalType,
            unitGuid: this.unitGuid
          },
          messageType: 0
        })
      }).then(({ data }) => {
        console.log(data)
        if (data.messageCode == 200) {
          let Arr = data.messageContent
          if (this.templateoption.length != 0) {
            this.templateoption = []
          }
          for (var i = 0; i < Arr.length; i++) {
            var itemObj = {
              label: Arr[i].templateName,
              value: Arr[i].templateGuid
            }
            this.templateoption.push(itemObj)
          }
        } else {
          this.$message.error(data.errorMessage)
        }
      })
    },
    //修改房间参数模板
    parameterdataFormSubmit() {
      this.$http({
        url: this.$http.adornUrl('/terminal/room-terminal-template-update'),
        method: 'post',
        data: this.$http.adornData({
          messageContent: {
            roomGuidList: this.roomGuidList,
            unitGuid: this.unitGuid,
            templateGuid: this.parameterdataForm.template,
            terminalType: 21
          },
          messageType: 0
        })
      }).then(({ data }) => {
        console.log(data)
        if (data.messageCode == 200) {
          this.$message({
            type: 'success',
            message: '修改成功!',
            duration: 200,
            onClose: () => {
              this.$emit('refreshDataList')
              this.parameterDialogFormVisible = false
            }
          })
        } else {
          this.$message.error(data.errorMessage)
        }
      })
    },
    // 门资料管理修改
    personnelinit(item, unitGuid, buildingid) {
      this.roomGuid = item.roomGuid
      this.terminalGuid = item.terminalGuid
      this.unitGuid = unitGuid
      console.log(item, unitGuid, buildingid)
      this.personnelFormVisible = true
      this.operatinincomesummaryofconsmptionVisible = true
    },

    personnelcloseDialog(done) {
      this.operatinincomesummaryofconsmptionVisible = false
      done()
    },
    // 通行记录
    // 父组件调用此函数，传值
    recordsinit(item, unitGuid, buildingid, treedata) {
      this.roomGuid = item.roomGuid
      console.log(item, unitGuid, buildingid)
      console.log(treedata)
      this.recordsFormVisible = true
      this.recordsdetailsVisible = true
    },
    // 关闭窗口
    recordscloseDialog(done) {
      done()
      this.recordsdetailsVisible = false
    },
    // 关闭窗口
    recordsvisible() {
      this.recordsFormVisible = false
      this.recordsdetails = false
      // 控制子节点
      this.recordsdetailsVisible = false
    },
    // 保存
    records() {}
  }
}
</script>

<style lang="scss" scoped>
.aecc {
  /deep/.el-dialog--center .el-dialog__body{
    padding-bottom: 0;
  }
  .el-form-item{
    margin-bottom:12px
  }
}
</style>
